CREATE TABLE [dbo].[TXEXTR_BANC]
(
[CO_EMPR] [dbo].[TD_VC_002] NOT NULL,
[NU_CNTB_EMPR] [dbo].[TD_IN_001_CONT] NOT NULL,
[CO_CNTA_EMPR] [dbo].[TD_VC_020_CNTA] NOT NULL,
[NU_ANNO] [dbo].[TD_IN_004_ANNO] NOT NULL CONSTRAINT [DF__TXEXTR_BA__NU_AN__2F2FFC0C] DEFAULT (datepart(year,getdate())),
[NU_MESE] [dbo].[TD_IN_002_MESE] NOT NULL,
[NU_SECU] [dbo].[TD_IN_001] NOT NULL,
[TI_DOCU] [dbo].[TD_VC_003] NOT NULL,
[NU_DOCU] [dbo].[TD_VC_020] NOT NULL,
[FE_DOCU] [dbo].[TD_DT_001] NOT NULL,
[CO_MONE] [dbo].[TD_VC_003] NOT NULL,
[TI_OPER] [dbo].[TD_VC_003] NOT NULL,
[IM_MVTO_DOCU] [dbo].[TD_NU_016_004] NOT NULL CONSTRAINT [DF__TXEXTR_BA__IM_MV__33008CF0] DEFAULT ((0)),
[NU_ANNO_CONS] [dbo].[TD_IN_001] NULL,
[NU_MESE_CONS] [dbo].[TD_IN_001] NULL,
[ST_FLAG] [dbo].[TD_VC_001_SINO] NOT NULL CONSTRAINT [DF__TXEXTR_BA__ST_FL__36D11DD4] DEFAULT ('N'),
[CO_USUA_CREA] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_CREA] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TXEXTR_BA__FE_US__38B96646] DEFAULT (getdate()),
[CO_USUA_MODI] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_MODI] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TXEXTR_BA__FE_US__39AD8A7F] DEFAULT (getdate())
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TXEXTR_BANC] ADD CONSTRAINT [CK__TXEXTR_BA__CO_CN__2E3BD7D3] CHECK (([CO_CNTA_EMPR]>='0' AND [CO_CNTA_EMPR]<='99999999999999999999'))
GO
ALTER TABLE [dbo].[TXEXTR_BANC] ADD CONSTRAINT [CK__TXEXTR_BA__IM_MV__33F4B129] CHECK (([IM_MVTO_DOCU]>=(0)))
GO
ALTER TABLE [dbo].[TXEXTR_BANC] ADD CONSTRAINT [CK__TXEXTR_BA__NU_AN__30242045] CHECK (([NU_ANNO]>=(0)))
GO
ALTER TABLE [dbo].[TXEXTR_BANC] ADD CONSTRAINT [CK__TXEXTR_BA__NU_AN__34E8D562] CHECK (([NU_ANNO_CONS]>=(0)))
GO
ALTER TABLE [dbo].[TXEXTR_BANC] ADD CONSTRAINT [CK__TXEXTR_BA__NU_CN__2D47B39A] CHECK (([NU_CNTB_EMPR]>=(1) AND [NU_CNTB_EMPR]<=(99)))
GO
ALTER TABLE [dbo].[TXEXTR_BANC] ADD CONSTRAINT [CK__TXEXTR_BA__NU_ME__3118447E] CHECK (([NU_MESE]>=(0) AND [NU_MESE]<=(13)))
GO
ALTER TABLE [dbo].[TXEXTR_BANC] ADD CONSTRAINT [CK__TXEXTR_BA__NU_ME__35DCF99B] CHECK (([NU_MESE_CONS]>=(0)))
GO
ALTER TABLE [dbo].[TXEXTR_BANC] ADD CONSTRAINT [CK__TXEXTR_BA__ST_FL__37C5420D] CHECK (([ST_FLAG]='N' OR [ST_FLAG]='S'))
GO
ALTER TABLE [dbo].[TXEXTR_BANC] ADD CONSTRAINT [CK__TXEXTR_BA__TI_OP__320C68B7] CHECK (([TI_OPER]='ABO' OR [TI_OPER]='CAR'))
GO
ALTER TABLE [dbo].[TXEXTR_BANC] ADD CONSTRAINT [XPKTXEXTR_BANC] PRIMARY KEY CLUSTERED  ([CO_EMPR], [NU_CNTB_EMPR], [CO_CNTA_EMPR], [NU_ANNO], [NU_MESE], [NU_SECU]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TXEXTR_BANC] ADD CONSTRAINT [FK1_TTCNTB_EMPR_A_TXEXTR_BANC] FOREIGN KEY ([CO_EMPR], [NU_CNTB_EMPR]) REFERENCES [dbo].[TTCNTB_EMPR] ([CO_EMPR], [NU_CNTB_EMPR])
GO
